#!/bin/bash

assert() {
  expected="$2"
  input="$1"

  ./rvcc $input > tmp.s
  gcc tmp.s -o tmp
  ./tmp

  if [ "$expected" -eq "$?" ]; then  # 使用 -eq 进行数值比较
    echo "OK: $input => $expected"
  else
    echo "ERROR: $input => $expected (实际结果: $?)"
    return 1
  fi
}

make

assert $1 $2
